//
//  ViewController.m
//  CommentDemo
//
//  Created by menghua liu on 2018/5/7.
//  Copyright © 2018年 hih-d-11371. All rights reserved.
//

#import "ViewController.h"
#import "STCommentEditView.h"
#import "STCommentToolView.h"


#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height

@interface ViewController ()<NFCommentToolViewDelegate, NFCommentEditViewDelegate>
@property (nonatomic, strong) STCommentEditView *editView;
@property (nonatomic, strong) STCommentToolView *commentToolView ;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIButton * testButton = [[UIButton alloc]initWithFrame:CGRectMake(100, 100, 100, 80)];
    testButton.layer.borderColor = [[UIColor redColor] CGColor];
    testButton.layer.borderWidth = 2.f;
    [testButton setTitle:@"手机用户" forState:UIControlStateNormal];
    [testButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [testButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview: testButton];
    
//    self.commentToolView = [[STCommentToolView alloc] initWithFrame:CGRectMake(0, 200, 0, 0)];
    self.commentToolView = [[STCommentToolView alloc] initWithDeafultFrame];
    self.commentToolView.commentCount = 1015;
    self.commentToolView.delegate = self;
    [self.view addSubview:self.commentToolView];
    
    self.editView = [[STCommentEditView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
    self.editView.delegate = self;
    [self.view addSubview:self.editView];
    self.editView.hidden = YES;
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    self.commentToolView.commentCount += 2701;
}

- (void)buttonClick:(UIButton *)button {
    [self.editView updatePlaceholder:@"回复手机用户："];
    self.editView.hidden = NO;
    [self.editView show];
}

#pragma mark - NFCommentToolViewDelegate

- (void)commentToolViewContentButtonClicked {
    NSLog(@"写评论...");
    
    [self.editView updatePlaceholder:@"优质内容将会优先展示"];
    self.editView.hidden = NO;
    [self.editView show];
}

- (void)commentToolViewShareButtonClicked {
    NSLog(@"点击了分享");
}

- (void)commentToolViewArticleButtonClicked {
    NSLog(@"点击了文章");
}

#pragma mark - NFCommentEditViewDelegate

- (void)commentEditView:(STCommentEditView *)commentEditView didRequsetStatus:(BOOL)success {
    if (success) {
        NSLog(@"发送成功！");
        
        // update comment count
        // ...
        
    } else {
        NSLog(@"发送失败");
    }
}


@end
